使用mb_send_mail方法发送html/plain格式的Email, HTML格式的邮件.
本方法将根据trim后的邮件内容设置email类型: 如果以"<"开始, 则将邮件设置为Html格式, 反之为plain格式.
/** * 发送报错邮件 by liguoliang.com * @return unknown_type */ function sendErrorEmail() { /** * 覆盖php.ini设置, 防止出现中文乱码. */ ini_set("mbstring.language", "Neutral"); ini_set("mbstring.internal_encoding", "UTF-8"); ini_set("mbstring.http_input", "UTF-8"); ini_set("mbstring.http_output", "UTF-8"); ini_set("mbstring.encoding_translation", "On"); ini_set("mbstring.detect_order", "auto"); ini_set("mbstring.substitute_character", "long"); $headers = 'Reply-To: [email protected]' . "\r\n"; $emailSubject = "email body goes here"; //$this->getReplacedStr($this->notifyEmailSubject); $emailBody = trim($this->getReplacedStr($this->notifyEmailBody)); if(mb_substr($emailBody, 0, 1) == "<" || mb_substr($emailBody, 0, 4) == "<") { $headers .= "Content-type: text/html; \r\n"; }else { $headers .= "Content-Type: text/plain; \r\n"; } $headers .= " charset=\"utf-8\"; \r\n"; return mb_send_mail($this->notifyEmailTo, $emailSubject, $emailBody, $headers); }
PHP: 使用fopen进行文件读写 <->
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.